package com.smm.imgServer.dao.impl;

import com.smm.imgServer.dao.ImageInfoDao;
import com.smm.imgServer.domain.ImageInfo;

import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by tangshulei on 2016/1/29.
 */
@Repository
public class ImageInfoDaoImpl extends MongodbDaoImpl<ImageInfo> implements ImageInfoDao  {

    protected Class<ImageInfo> getEntityClass() {
        return ImageInfo.class;
    }

    public ImageInfo queryOne(ImageInfo imageInfo){
        Query query = new Query();
        query.addCriteria(Criteria.where("clientId").is(imageInfo.getClientId()));
        query.addCriteria(Criteria.where("imageName").is(imageInfo.getImageName()));
        ImageInfo image = this.mongoTemplate.findOne(query, ImageInfo.class, getCollectionName());
        return image;
    }

}
